package com.ruoyi.web.rmNew.service.http;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.inter.HttpHostProvider;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.web.core.config.ConfigLoader;
import com.ruoyi.web.cp.service.http.ObHttpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ObHttpService2 {
    @Autowired
    private ObHttpService obHttpService;
    private static HttpHostProvider httpHostProvider;

    @Autowired
    public void setHttpHostProvider(HttpHostProvider provider) {
        httpHostProvider = provider;
    }

    public void sendObDetail(String gameid, String path) {
        long beginTime = System.currentTimeMillis();
        JSONObject header = obHttpService.getObHeaders();
        String url = ConfigLoader.getConfig().getObHost() + "yewu11/v1/w/matchDetail/getMatchOddsInfo1?mcid=0&mid=" + gameid + "&cuid=511491216875443815&newUser=0&t=" + beginTime;
        JSONObject res = HttpUtils.httpJsonNewHg("cp/obGameDetail", url, "post", null, header);
        FileUtil.writeString(res.toJSONString(), path, "utf8");
        ThreadUtil.sleep(1000);
    }
}
